package com.ruoyi.system.service.req;

import com.ruoyi.common.core.domain.entity.RestaurantStoreResource;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.math.BigDecimal;
import java.util.Date;

/**
 * @Author: ruohao
 * @Date: 2023/8/27
 **/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class UpdateResourceDTO {
    @NotNull(message = "食材id不能为空")
    private Long id;

//    @NotBlank(message = "食材图片不能为空")
    private String imageUrl;

    private Date guarantee;

    private String unit;

    private String type;

    private BigDecimal avgPrice;

    private BigDecimal up;

    private BigDecimal down;

    public static RestaurantStoreResource convertToDO(UpdateResourceDTO updateResourceDTO) {
        if (updateResourceDTO == null) {
            return null;
        }
        return RestaurantStoreResource.builder()
            .id(updateResourceDTO.getId())
            .imageUrl(updateResourceDTO.getImageUrl())
            .up(updateResourceDTO.getUp())
            .down(updateResourceDTO.getDown())
            .guarantee(updateResourceDTO.getGuarantee())
                .avgPrice(updateResourceDTO.getAvgPrice())
                .unit(updateResourceDTO.getUnit())
                .type(updateResourceDTO.getType())
            .build();
    }
}
